#ifndef _FNT_COMPUTE_THREAD_OPTIONS_H_
#define _FNT_COMPUTE_THREAD_OPTIONS_H_

#include "options.page.h"
#include "plugins/plugin.h"
//class QSpinBox;s

#include <QLabel>
class QFormLayout;
#include <QComboBox>

#include <QList>
#include <QDoubleSpinBox>
#include <QSpinBox>
struct ComputeThreadPriv;
class ComputeGeneralOptions: public OptionsPage {
	ComputeThreadPriv* ctp;
	int intervalDef;
	int intervalSet;
	QSpinBox* spinbox;
	bool disabled;

	static ComputeGeneralOptions* _instance;

	ComputeGeneralOptions();
	~ComputeGeneralOptions();

	void getState(bool* a, bool* b, bool* c, bool* d) const override;
	void setStateImp(SessionState ts) override;
	void useDefaultImp() override;
	void saveDefaultImp() override;
	void applyChangesImp() override;
	void resetChangesImp() override;

	private Q_SLOTS:
	void spinboxChanged(int v);

	public:
	void config(ComputeThreadPriv* _ctp, Options* options) const;
	void saveConfig(ComputeThreadPriv* _ctp, Options* options) const;
	void attach(ComputeThreadPriv* _ctp);

	static ComputeGeneralOptions* instance() {
		if(!_instance)
			_instance=new ComputeGeneralOptions{};
		return _instance;
	}
};

enum AlgType {
	ALG_FIND=0,
	ALG_CONN,
	ALG_REFINE,
	ALG_REFINE_AUTO
};


template<AlgType typ>
class ComputeAlgOptions: public OptionsPage {
	ComputeThreadPriv* ctp;
	int idxUsed;
	int idxSet;
	int idxDef;
	std::vector<ParamValue> valsUsed;
	std::vector<ParamValue> valsSet;
	std::vector<ParamValue> valsDef;
	QVector<bool> chgsUsed;
	QVector<bool> chgsDef;
	QComboBox* chooser;
	QLabel* descLabel;
	QFormLayout* layoutForm;
	QList<QWidget*> entries;
	QList<QLabel*> labels;
	bool disabled;

	static ComputeAlgOptions<typ>* _instance;

	ComputeAlgOptions();
	~ComputeAlgOptions();

	void useDefaultImp() override;
	void saveDefaultImp() override;
	void resetChangesImp() override;
	void getState(bool* a, bool* b, bool* c, bool* d) const override;
	void setStateImp(SessionState ts) override;
	void applyChangesImp() override;

	template<bool global>
	void saveOptions(Options* options);
	void setParams(const QVector<bool>& chgs, const std::vector<ParamValue>& vals);

	public Q_SLOTS:
	void algorithmChanged(int idx);
	void setChooser(int index)	{
		chooser->setCurrentIndex(index);
	}

	public:

	void config(ComputeThreadPriv* _ctp, Options* options) const;
	void saveConfig(ComputeThreadPriv* _ctp, Options* options) const;
	void attach(ComputeThreadPriv* _ctp);
    static ComputeAlgOptions<typ>* instance() {
        if(!_instance)
            _instance=new ComputeAlgOptions<typ>{};
        return _instance;
    }
};
// #include "compute.thread.options.cc"
#endif
